package net.huashitong.user.service;

import java.util.List;


import com.sirdc.modules.core.filter.Paging;
import net.huashitong.user.dao.CollectionDao;
import net.huashitong.user.entity.Collection;
import net.huashitong.user.filter.CollectionFilter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;

@Service
public class CollectionService extends StringPKService<Collection> {
	@Autowired
	private SysTableService tableService;
	@Autowired
	private CollectionDao dao;
	@Override
	protected BaseDao<Collection, String> getDao() {
		// TODO Auto-generated method stub
		return dao;
	}
	@Override
	protected void beforeSave(Collection collection) {
		collection.setSysId(tableService.updateMaxSysId("t_gis_collection", null));
	}
	public List<Collection> queryByUserId(CollectionFilter filter) {

		if (filter.getCurrentPage() == null||filter.getCurrentPage()==-1) {
			filter.setCurrentPage(1);
		}
		Paging p = new Paging();
		p.setCurrentPage(Integer.valueOf(filter.getCurrentPage()));
		filter.setPaging(p);
		return dao.queryByUserId(filter);
	}
	
	public Collection getByUserIdAndSome(CollectionFilter filter) {
		return dao.getByUserIdAndAlertId(filter);
	}
}
